import React from 'react';
import { lazy, Suspense } from 'react';
import { Spin } from 'antd';

import Login from '../components/login/Login';
import Register from '../components/login/Register';
import AuditUser from '../components/user/AuditUser';
import DataAudit from '../components/dataAudit/DataAudit';
import DataManage from '../components/dataManage/DataManage';

const Map = lazy(() => import('../components/map/Map'));

const lazyLoad = (children) => {
    return <Suspense fallback={<Spin />}>{children}</Suspense>;
};

const router = [
    {
        path: '/',
        element: lazyLoad(<Map />),
    },
    {
        path: '/login',         // 登录
        element: lazyLoad(<Login />),
    },
    {
        path: '/register',      // 注册
        element: lazyLoad(<Register />),
    },
    {
        path: '/auditUser',     // 用户审核
        element: lazyLoad(<AuditUser />),
    },
    {
        path: '/dataAudit',     // 数据审核
        element: lazyLoad(<DataAudit />),
    },
    {
        path: '/dataManage',    // 数据管理
        element: lazyLoad(<DataManage />)
    }
];

export default router;
